import cv2
import numpy as np

img = np.zeros((200, 200), np.uint8)
img[50:150, 50:150]=255
img2 = np.zeros((200, 200), np.uint8)
img2[80:180, 80:180]=255
new_img = cv2.bitwise_xor(img, img2)
while True:
    cv2.imshow('img', img)
    cv2.imshow('img2', img2)
    cv2.imshow('new_img', new_img)
    key = cv2.waitKey(10)
    if key & 0xFF == ord('q'):
        break

cv2.destroyAllWindows()